package com.pan.kang.demo.support;


import com.pan.kang.core.PostProcessParam;
import com.pan.kang.core.PostProcessPlanProxy;
import com.pan.kang.core.PostProcessTask;
import com.pan.kang.demo.model.CreateOrderModel;
import com.pan.kang.executor.TaskExecutors;
import org.springframework.stereotype.Component;

import java.util.LinkedList;
import java.util.List;

@Component
public class CreateOrderPostProcessPlanProxy implements PostProcessPlanProxy<CreateOrderModel, Object> {
    @Override
    public List<PostProcessTask> plan(PostProcessParam.PlanTask<CreateOrderModel, Object> param) {
        // 一般通过数据库配置
        List<PostProcessTask> postProcessTaskList = new LinkedList<>();
        PostProcessTask orderHistoryTask = new PostProcessTask();
        postProcessTaskList.add(orderHistoryTask);
        orderHistoryTask.setExecutorId(TaskExecutors.OrderHistoryExecutor.name());
        orderHistoryTask.setAsync(true);
        PostProcessTask clearShoppingCardTask = new PostProcessTask();
        postProcessTaskList.add(clearShoppingCardTask);
        clearShoppingCardTask.setExecutorId(TaskExecutors.ClearShoppingCardExecutor.name());
        clearShoppingCardTask.setAsync(false);
        PostProcessTask reduceSkuStockTask = new PostProcessTask();
        postProcessTaskList.add(reduceSkuStockTask);
        reduceSkuStockTask.setExecutorId(TaskExecutors.ReduceSkuStockExecutor.name());
        reduceSkuStockTask.setAsync(false);
        return postProcessTaskList;
    }
}
